#include "vcard.h"
#include "util.h"

int Vcard::GetCount() const{
	return this->lineNum;
}
string Vcard::GetLine(const int index) const{
	return this->texts[index];
}


void Vcard::InsertLine(const string & line)
{
	int i;
	for(i=0; i<this->lineNum; i++){
		if(line.compare(this->texts[i]) == 0){
			break;
		}
	}
	if(i == this->lineNum){
		this->texts[this->lineNum] = line;
		this->lineNum++;
	}
}

void Vcard::InsertVcard(const Vcard &vcard){
	for(int i=0; i<vcard.GetCount(); i++){
		this->InsertLine( vcard.GetLine(i) );
	}

}

const string  Vcard::GetName() const
{
	for(int i=0; i<this->GetCount(); i++){
		if( Util::StringStartWith( this->GetLine(i),  "FN:") ){
			return this->GetLine(i);
		}
	}
	return "";

}

void Vcard::Clear(){
	this->lineNum = 0;
}

Vcard::Vcard(void)
{
	Clear();
}

Vcard::~Vcard(void)
{
}
